#include "../../framework/framework.h"
#include "../inc/xD3DEnv.h"
namespace Sky
{
	xD3DEnv::xD3DEnv()
	{
		Initialise();
	}

	xD3DEnv::~xD3DEnv()
	{
		Finalise();
	}

	TResult xD3DEnv::onCreate(xDxApp* app )
	{
		if(!D3DXCheckVersion(D3D_SDK_VERSION,D3DX_SDK_VERSION))
		{
			return myDe_Trace_hr0(S,XE_VERSION,_XT("version is not right"));
		}
		if(m_Res == vNull)
		{
			m_Res=Direct3DCreate9(D3D_SDK_VERSION);
			if(m_Res == vNull)
			{
				return myDe_Trace_hr0(S,XE_APICALL,_XT("Direct3DCreate9() failed"));
			}
		} // if(mRes == vNull)
		return XE_OK;
	}
	TResult xD3DEnv::onDelete(xDxApp* app )
	{
		Finalise();
		return XE_OK;
	}

	TVoid xD3DEnv::Initialise()
	{
		m_Res = vNull;
	}

	TVoid Sky::xD3DEnv::Finalise()
	{
		SAFE_RELEASE(m_Res);
	}




}